package com.idanchuang.count.controller;

import com.idanchuang.component.base.exception.core.asserts.ExBusinessAssert;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author Richard_yyf
 * @version 1.0 2021/5/27
 */
@Component
public class ParamsChecker {

    @Value("${count.update.batch-size-limit:3}")
    private int updateBatchLimit;

    @Value("${count.query.batch-size-limit:20}")
    private int queryBatchLimit;

    @Value("${msg.add.batch-size-limit:1000}")
    private int msgAddBatchLimit;

    @Value("${msg.reset.batch-size-limit:1000}")
    private int resetBatchSizeLimit;

    public void checkUpdateBatchSize(int input) {
        ExBusinessAssert.isTrue(input <= updateBatchLimit,
                "超过批量限制, limit: {}, input: {}", updateBatchLimit, input);
    }

    public void checkQueryBatchSize(int input) {
        ExBusinessAssert.isTrue(input <= queryBatchLimit,
                "超过批量限制, limit: {}, input: {}", queryBatchLimit, input);
    }

    public void checkMsgAddBatchSize(int input) {
        ExBusinessAssert.isTrue(input <= msgAddBatchLimit,
                "超过批量限制, limit: {}, input: {}", msgAddBatchLimit, input);
    }

    public void checkResetBatchSize(int input) {
        ExBusinessAssert.isTrue(input <= resetBatchSizeLimit,
                "超过批量限制, limit: {}, input: {}", resetBatchSizeLimit, input);
    }
}
